package com.haoze.nurseapp.service;

import com.haoze.nurseapp.service.impl.MyQuartzJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class QuartzDemo {
    private void QuartzTest(){
//        try {
//            //获取调度器
//            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
//            scheduler.start();
//            //创建任务器：定义任务细节
//            JobDetail jobDetail = JobBuilder.newJob(MyQuartzJob.class).withIdentity("job1", "group1").build();
//            ScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(5).repeatForever();
//            //定义触发器
//            Trigger trigger=TriggerBuilder.newTrigger().withIdentity("simpleTrigger", "simpleTriggerGroup")
//                    .withSchedule(scheduleBuilder).startNow().build();
//
//            //将任务和触发器注册到调度器中
//            scheduler.scheduleJob(jobDetail, trigger);
//            // 启动
//            if (!scheduler.isShutdown()) {
//                scheduler.start();
//            }
//        } catch (SchedulerException e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
    }
}
